package com.hannesdorfmann.mosby3.mvp.widget;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.app.Context;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class CirleProgressImgTest {

    @Test
    public void firtLoadStart() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        CirleProgressImg cirleProgressImg = new CirleProgressImg(context);
        cirleProgressImg.firtLoadStart();

        assertTrue(!cirleProgressImg.getmAnimator().isPaused());
        assertTrue(cirleProgressImg.getVisibility() == Component.VISIBLE);
    }

    @Test
    public void startAnime() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        CirleProgressImg cirleProgressImg = new CirleProgressImg(context);
        cirleProgressImg.startAnime();

        assertTrue(!cirleProgressImg.getmAnimator().isPaused());
        assertTrue(cirleProgressImg.getVisibility() == Component.VISIBLE);
    }

    @Test
    public void start() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        CirleProgressImg cirleProgressImg = new CirleProgressImg(context);
        cirleProgressImg.start();

        assertTrue(!cirleProgressImg.getmAnimator().isPaused());
        assertTrue(cirleProgressImg.getVisibility() == Component.VISIBLE);
    }

    @Test
    public void stop() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        CirleProgressImg cirleProgressImg = new CirleProgressImg(context);
        cirleProgressImg.start();
        assertTrue(cirleProgressImg.getVisibility() == Component.VISIBLE);

        cirleProgressImg.stop();
        assertTrue(!cirleProgressImg.getmAnimator().isRunning());
    }

    @Test
    public void setVisibility() {

        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        CirleProgressImg cirleProgressImg = new CirleProgressImg(context);
        cirleProgressImg.start();
        assertTrue(cirleProgressImg.getVisibility() == Component.VISIBLE);

        cirleProgressImg.setVisibility(Component.HIDE);
        assertTrue(!cirleProgressImg.getmAnimator().isRunning());
    }
}